package com.xcity.game.activity.exchange;

import com.xcity.game.item.ItemInfo;

import naga.x.game.template.Template;
import naga.x.game.template.TemplateException;
import naga.x.game.template.annotation.Excel;

/**
 * 物品兑换活动
 * @author yang.li
 *
 */
@Excel(value = "activity.xlsx", sheet = 3)
public class ItemExchangeTemplate extends Template {

	/** 兑换物品id */
	protected int itemId;

	/** 兑换数量 */
	protected int itemCount;

	/** 需求物品1id */
	protected int[] requires;
	protected ItemInfo[] requireItems;

	public int getItemId() {
		return itemId;
	}

	public void setItemId(int itemId) {
		this.itemId = itemId;
	}

	public int getItemCount() {
		return itemCount;
	}

	public void setItemCount(int itemCount) {
		this.itemCount = itemCount;
	}

	public int[] getRequires() {
		return requires;
	}

	public void setRequires(int[] requires) {
		this.requires = requires;
	}

	public ItemInfo[] getRequireItems() {
		return requireItems;
	}

	public void setRequireItems(ItemInfo[] requireItems) {
		this.requireItems = requireItems;
	}

	@Override
	public void validate() throws TemplateException {
		int len = requires.length;
		requireItems = new ItemInfo[len >> 1];
		for (int i = 0; i < len; i += 2) {
			ItemInfo item = new ItemInfo(requires[i], requires[i + 1]);
			requireItems[i >> 1] = item;
		}
	}
}
